package com.mrd.gtimp.base.entity;

import org.hibernate.annotations.GenericGenerator;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;

/**
 * <p> application name: gtimp <p> copyright: Copyright@2012 明睿达科技有限公司
 */

/**
 * 角色对象
 *
 * @author qiul
 */
@Entity(name = "t_sys_role")
@org.hibernate.annotations.Entity(dynamicUpdate = true)
public class Role implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "roleGenerator")
    @GenericGenerator(name = "roleGenerator", strategy = "uuid")
    @Column(name = "id")
    private String id;
    /**
     * 角色名称
     */
    @Column(name = "name")
    private String name;
    /**
     * 启用状态
     */
    @Column(name = "r_state", nullable = false)
    private String state;

    /**
     * 角色模块权限
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_SYS_ROLE_MODULE", inverseJoinColumns = @JoinColumn(name = "moduleid"),
            joinColumns = @JoinColumn(name = "roleid"))
    private List<Module> modules;
    /**
     * 角色功能权限
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_SYS_ROLE_PERMISSIONS", inverseJoinColumns = @JoinColumn(
            name = "permissionsid"), joinColumns = @JoinColumn(name = "roleid"))
    private List<Permissions> permissions;
    /**
     * 角色可管理模块
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_SYS_ROLE_M_MODULE", inverseJoinColumns = @JoinColumn(name = "moduleid"),
            joinColumns = @JoinColumn(name = "roleid"))
    private List<Module> manageModules;
    /**
     * 角色可管理权限
     */
    @ManyToMany(fetch = FetchType.LAZY)
    @JoinTable(name = "T_SYS_ROLE_M_PERMISSIONS", inverseJoinColumns = @JoinColumn(
            name = "permissionsid"), joinColumns = @JoinColumn(name = "roleid"))
    private List<Permissions> managePermissions;
    /**
     * 角色所属公司
     */
    @ManyToOne
    @JoinColumn(name = "compnayid", referencedColumnName = "COM_ID")
    private Company company;

    @ManyToMany
    @JoinTable(name = "T_SYS_ROLE_USER", inverseJoinColumns = @JoinColumn(name = "USER_ID"),
            joinColumns = @JoinColumn(name = "ROLE_ID"))
    private List<User> users;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Module> getModules() {
        return modules;
    }

    public void setModules(List<Module> modules) {
        this.modules = modules;
    }

    public List<Permissions> getPermissions() {
        return permissions;
    }

    public void setPermissions(List<Permissions> permissions) {
        this.permissions = permissions;
    }

    public List<Module> getManageModules() {
        return manageModules;
    }

    public void setManageModules(List<Module> manageModules) {
        this.manageModules = manageModules;
    }

    public List<Permissions> getManagePermissions() {
        return managePermissions;
    }

    public void setManagePermissions(List<Permissions> managePermissions) {
        this.managePermissions = managePermissions;
    }

    public Company getCompany() {
        return company;
    }

    public void setCompany(Company company) {
        this.company = company;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }

}
